import axios from 'axios'
import {Notice} from 'view-design'
import 'view-design/dist/styles/iview.css'

// 创建 axios 对象并设置默认 url
const service = axios.create({
    baseURL: "/api"
})

// 响应拦截器
service.interceptors.response.use(response => {
    let msg = response.data.message
    if (msg != null) {
        if (response.data.status === 200) {
            Notice.success({
                title: '提示',
                desc: msg
            })
            return response.data.data
        } else {
            Notice.warning({
                title: '警告',
                desc: msg
            })
        }
    } 
    else if (response.data.status === 200) {
        return response.data.data
    }
})

export default service